package com.vf.admin.miaodong.dao;

import com.vf.admin.common.db.BaseDao;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.WechatPayConfigs;
import com.vf.admin.miaodong.entity.WxAppidConfig;
import com.vf.admin.miaodong.entity.WxAppletConfigs;
import com.vf.admin.utils.StringEx;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>Title : </p>
 * <p>Description : </p>
 * <p>DevelopTools : IDEA</p>
 * <p>DevelopSystem : Windows11</p>
 *
 * @Author : NemoMeng
 * @Date 2023/12/28 11:38
 */
@Repository
public class AfterWxAppidConfigDao extends BaseDao<WxAppidConfig>  {
    public List<WxAppidConfig> list(Map<String, Object> map, SplitPageBean splitPage) {
        List<Object> paramList = new ArrayList<>();
        StringBuilder sbStr = new StringBuilder("");
        sbStr.append(" SELECT a.* FROM wx_appid_config a where 1=1 ");
        String sql = sbStr.toString();
        return this.queryList(sql, paramList, WxAppidConfig.class, splitPage);
    }

    public WxAppidConfig getById(Integer id) {
        if (StringEx.isNullOrLing(id)) {
            return null;
        }
        List<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder("select * from wx_appid_config where id = ? ");
        paramList.add(id);
        String sql = sbStr.toString();
        return this.queryObj(sql, paramList, WxAppidConfig.class);
    }

    public void saveOrUpdate(WxAppidConfig params) {
        if (params.getId() != null && params.getId() > 0) {
            this.update(params);
        } else {
            params.setId(this.add(params));
        }
    }

    public void delById(Integer id) {
        if (id == null || id <= 0) {
            return;
        }
        String sql = "delete from wx_appid_config where id = ?";
        ArrayList<Object> paramList = new ArrayList<Object>();
        paramList.add(id);
        this.del(sql, paramList);
    }
}
